该 客户端-服务器编程模型 是分布式应用的基础架构。它并非由硬件定义,而是由一种 逻辑事务 在两个进程之间进行的:一个 客户端 发起对某个 资源的请求,而另一个 服务器 负责管理并提供该资源。
1. 四步事务流程
每次交互都遵循严格的顺序:(1) 客户端发送请求;(2) 服务器解析并操作本地资源;(3) 服务器发送响应;(4) 客户端处理接收到的数据(例如渲染 HTML)。
2. 硬件结构
通信依赖于 网络适配器,这是一种输入/输出设备。数据从 CPU 经由 I/O 桥接器 和 系统总线 传输到 主内存。在类似 http://www.google.com:80的网络请求中,数据包会通过这些总线到达应用程序代码。
3. 协议抽象
现代应用程序使用 网络字节序(大端模式) 以确保一致性。像 getaddrinfo 这样的函数可实现 域名到 IP 地址的映射 同时保持与协议无关性。
main.py
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
QUESTION 1
What if different networks have different maximum frame sizes (MTUs)?
The packet is discarded by the first router.
Routers and IP software handle fragmentation and reassembly.
The sender must manually resend smaller frames.
The network automatically increases its MTU.
✅ Correct!
Correct! Routers break larger packets into smaller fragments to fit the network's constraints.❌ Incorrect
Protocols handle this automatically through fragmentation and reassembly.QUESTION 2
Can a single physical host run both a client process and a server process simultaneously?
No, it causes a hardware conflict on the I/O Bus.
Yes, network applications are process-level interactions.
Only if it has two separate Network Adapters.
Only if one uses IPv4 and the other uses IPv6.
✅ Correct!
The client-server model is a distributed structure partitioned between processes, not hardware units.❌ Incorrect
A host can run many processes. For example, your PC can run a web browser (client) and a local database (server).QUESTION 3
In the 4-step transaction, what is the server's immediate action after receiving a request?
Render the HTML content.
Send an acknowledgement to the router.
Interpret the request and manipulate resources.
Terminate the connection to save bandwidth.
✅ Correct!
Step 2 involves the server processing the request and fetching or calculating the resource.❌ Incorrect
Rendering is done by the client; sending the response happens in Step 3.QUESTION 4
Which hardware component bridges the Network Adapter to the CPU and Main Memory?
The ALU
The I/O Bridge
The Register File
The USB Controller
✅ Correct!
The I/O Bridge manages the flow of data between the I/O bus (where the adapter sits) and the memory/system buses.❌ Incorrect
The ALU performs calculations; the I/O Bridge manages the data path.QUESTION 5
What is the standard byte order for data transmitted over the Internet?
Little-endian
Network byte order (big-endian)
Host-native order
Bi-endian
✅ Correct!
Network Byte Order is defined as big-endian to ensure cross-platform compatibility.❌ Incorrect
Little-endian is common in x86 hosts, but the network protocol requires Big-endian.Case Study: The 'hostname' Transaction
Analyzing a system command through the Client-Server lens.
A student runs the command
linux> hostname on a terminal. This simple utility follows the client-server model to retrieve the machine's name from the operating system.Q
1. Identify the 'Client Process' and 'Server Process' in this local scenario.
Solution:
The terminal/command process acts as the client requesting the resource. The Operating System kernel acts as the server, managing the system's identity resource.
The terminal/command process acts as the client requesting the resource. The Operating System kernel acts as the server, managing the system's identity resource.
Q
2. Trace the data path when the server returns the 'hostname' string from memory to the display.
Solution:
The data moves from Main Memory through the I/O Bridge, across the I/O Bus to the Graphics Adapter for display on the screen.
The data moves from Main Memory through the I/O Bridge, across the I/O Bus to the Graphics Adapter for display on the screen.
Q
3. If this were a remote request via a web browser, what 'well-known service name' and port would likely be involved?
Solution:
A web browser request typically uses the http service name on port 80.
A web browser request typically uses the http service name on port 80.